import time
from selenium import webdriver
from selenium.webdriver.common.by import By
import os

sp = os.path.abspath('html')
ap = os.path.join(sp,'frame.html')
driver = webdriver.Chrome()
driver.get(ap)
#进入f1iframe
frame = driver.find_element(By.CSS_SELECTOR,'#f1')
driver.switch_to.frame(frame)
#进入f2iframe  注意：嵌套的iframe需要一层一层切
driver.switch_to.frame('f2')
# 回到父级
driver.switch_to.parent_frame()
#回到top
driver.switch_to.default_content()


